package top.sehnsucht.service.impl;

import top.sehnsucht.dao.PhotoDao;
import top.sehnsucht.dao.UserPhotoDao;
import top.sehnsucht.service.UserPhotoService;
import top.sehnsucht.vo.UserInfo;
import top.sehnsucht.vo.UserPhoto;

import java.util.ArrayList;
import java.util.Date;
import java.util.Map;

/**
 * @Description:
 * @Author: Cai
 * @CreateTime: 2021/11/12
 */

public class UserPhotoServiceImpl implements UserPhotoService {
    private UserPhotoDao userPhotoDao;

    public UserPhotoServiceImpl(UserPhotoDao userPhotoDao) {
        this.userPhotoDao = userPhotoDao;
    }

    /**
     * 返回ArrayList<ArrayList<String>>,方便转成json传到前端
     * 只有用户信息
     * id,姓名,生日
     * @return
     */
    @Override
    public ArrayList<Map<String, String>> getAllUser() {
        return userPhotoDao.getAllUser();
    }

    /**
     * 添加photo和user到数据库中
     * @param userPhotos
     */
    @Override
    public void addUserAndPhoto(ArrayList<UserPhoto> userPhotos) {
        userPhotoDao.addUserAndPhoto(userPhotos);
    }

    /**
     * 根据id查找图片集合
     * @param id
     * @return
     */
    @Override
    public ArrayList<UserPhoto> getPhotoByUserId(Integer id) {
        return userPhotoDao.getPhotoByUserId(id);
    }

    /**
     * 插入用户,返回用户id
     * @param userInfo
     * @return
     */
    @Override
    public Integer addUser(UserInfo userInfo) {
        return userPhotoDao.addUser(userInfo);
    }

    /**
     * 根据要求查看用户
     * @param name
     * @param startDate
     * @param endDate
     * @return
     */
    @Override
    public ArrayList<Map<String, String>> getSomeUser(String name, String startDate, String endDate) {
        return userPhotoDao.getSomeUser(name, startDate, endDate);
    }
}
